#ifndef TOWER_CPP
#define TOWER_CPP
#include "Tower.h"
#include "Renderer.h"
#include "Enemy.h"
#include <new>
#define SHOOT_COOLDOWN 10
Tower::Tower(int x, int y)
{
	m_objectType = OBJECT_TYPE::TOWER;

	m_damage = 1;
	m_range = 80;
	m_shootCooldown = 0;
	Position& pos = GetPosition();
	pos.x = x;
	pos.y = y;
	pos.height = 10;
	pos.width = 10;
}
Tower::~Tower(void)
{

}
void Tower::DestroyData(void)
{
	//Renderer::GetInstance().FreeTexture(m_texture);
}
int Tower::GetDamage(void)
{
	return m_damage;
}
float Tower::GetRange(void)
{
	return m_range;
}
void Tower::Copy(void* address)
{
	new (address)Tower(*this);
}
bool Tower::Shoot(GameObject* target)
{
	if (!m_shootCooldown)
	{
		m_shootCooldown = SHOOT_COOLDOWN;
		return ((Enemy*)target)->Hit(m_damage);
	}
	return false;
}
void Tower::Update(void)
{
	if (m_shootCooldown)
	{
		m_shootCooldown--;
	}
}
void Tower::Draw(void)
{
	Renderer::GetInstance().DrawObject(*this);
}
int Tower::GetObjSize(void)
{
	return sizeof(*this);
}
SDL_Texture* Tower::GetTexture(void)
{
	static SDL_Texture* texture = 0;
	if (!texture)
	{
		texture = Renderer::GetInstance().LoadTexture("c:/nerd.bmp"); 
	}
	return texture;
}

#endif